package com.david.controller;

import com.david.service.OrderGatewayService;
import com.david.service.OrderService;
import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description: OrderController
 * @Author: wangwei
 * @CreateDate: 2022/1/13 11:04
 */
@RestController
@Slf4j
//@DefaultProperties(defaultFallback ="globalHandler" )
public class OrderController {

    @Resource
    private OrderGatewayService orderService;


    @GetMapping("/consumer/payment/consul")
//    @HystrixCommand(fallbackMethod = "paymentConsulHandler",commandProperties = {
//            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",value = "1000")
//    })
    public String paymentConsul(){
        return orderService.paymentConsul();
    }

    @GetMapping("/consumer/payment/consul1")
//    @HystrixCommand
    public String paymentConsul1(){
        return orderService.paymentConsul();
    }


    public String paymentConsulHandler(){

        return "paymentConsulHandler80服务器出错，稍后重试！";
    }

    public String globalHandler(){

        return "Global服务器出错，稍后重试！";
    }

}

